﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MudEngine.Parsing.AST
{
	public class AType
	{
		public static AType TYPE_VOID = new AType(ResultType.VOID);
		public static AType TYPE_BOOL = new AType(ResultType.BOOL);
		public static AType TYPE_SHORT = new AType(ResultType.SHORT);
		public static AType TYPE_INT = new AType(ResultType.INT);
		public static AType TYPE_LONG = new AType(ResultType.LONG);
		public static AType TYPE_STRING = new AType(ResultType.STRING);
		public static AType TYPE_OBJECT = new AType(ResultType.OBJECT);
		public static AType TYPE_REAL = new AType(ResultType.REAL);
        public static AType TYPE_VAR = new AType(ResultType.VAR);
        public static AType TYPE_MAP = new AType(ResultType.MAP);
        public static AType TYPE_ARRAY = new AType(ResultType.ARRAY);
        public static AType TYPE_UNKNOWN = new AType(ResultType.UNKNOWN);
        public static AType TYPE_FUNCTION = new AType(ResultType.FUNCTION);

		public ResultType _systemType;
		public string _customType = string.Empty;

		private AType(ResultType systemType)
		{
			this._systemType = systemType;
		}

		public AType(string customType)
		{
			this._systemType = ResultType.UNKNOWN;
			this._customType = customType;
		}

		public ResultType SystemType
		{
			get
			{
				return _systemType;
			}
		}

		public override string ToString()
		{
			return _systemType == ResultType.UNKNOWN ? _customType + "(UNKNOWN)" : _systemType.ToString();
		}
    }


    [Flags]
    public enum ResultType
    {
        UNKNOWN = 0,
        VOID = 1,
        BOOL = 2,
        SHORT = 4,
        INT = 8,
        LONG = 16,
        STRING = 32,
        OBJECT = 64,
        REAL = 128,
        VAR = 256,
        FUNCTION = 512,
        MAP = 1024,
        ARRAY = 2048
    }
}
